package cn.tedu.review;
/**
 * @Author 金帮嘉诚
 * @Date 2021-06-16 周三 9:36
 */
/*本类用于复习String中难点方法*/

import java.util.Arrays;

/**
 * 知识点：
 */
public class ReviewStringAPI {
    public static void main(String[] args) {
        String s = "a b c d e";
        String[] a=s.split(" ");
        System.out.println("a[0] = " + a[0]);
        System.out.println("a[1] = " + a[1]);
        System.out.println("a[2] = " + a[2]);
        System.out.println("a[3] = " + a[3]);
        System.out.println("a[4] = " + a[4]);
        //分割后空格消失，函数又给其加了一个空格
        System.out.println("Arrays.toString(s.split(\" \")) = " + Arrays.toString(s.split(" ")));
        System.out.println("Arrays.toString(s.split(\" \")) = " + Arrays.toString(s.split("b")));
        System.out.println("Arrays.toString(s.split(\" \")) = " + Arrays.toString(s.split("c")));
        System.out.println("Arrays.toString(s.split(\" \")) = " + Arrays.toString(s.split("%")));

        String s1="a*b*c*d*e";
        System.out.println("Arrays.toString(s1.split(\" \\*\")) = " + Arrays.toString(s1.split("\\*")));
//        a[0] = a
//        a[1] = b
//        a[2] = c
//        a[3] = d
//        a[4] = e
//        Arrays.toString(s.split(" ")) = [a, b, c, d, e]
//        Arrays.toString(s.split(" ")) = [a ,  c d e]
//        Arrays.toString(s.split(" ")) = [a b ,  d e]
//        Arrays.toString(s.split(" ")) = [a b c d e]
//        Arrays.toString(s1.split(" \*")) = [a, b, c, d, e]
        String s2="IHaveABigDick";
        String[] a1=s2.split("a");
        for (int i = 0; i <a1.length ; i++) {
            System.out.println("a1["+i+"] = " + a1[i]);
            //区分大小写
//            a1[0] = IH
//            a1[1] = veABigDick
        }
    }
}
